home *** CD-ROM | disk | FTP | other *** search
- /*
- ** Apple Macintosh Developer Technical Support
- **
- ** File: File.c
- ** Written by: Eric Soldan
- **
- ** Copyright © 1990-1993 Apple Computer, Inc.
- ** All rights reserved.
- */
-
- /* You may incorporate this sample code into your applications without
- ** restriction, though the sample code has been provided "AS IS" and the
- ** responsibility for its operation is 100% yours. However, what you are
- ** not permitted to do is to redistribute the source as "DSC Sample Code"
- ** after having made changes. If you're going to re-distribute the source,
- ** we require that you make it clear in the source that the code was
- ** descended from Apple Sample Code, but that you've made changes. */
-
- /* This file is where you place various definitions and constant values for
- ** DTS.Lib..framework's use. You will also add some code within the two
- ** functions to handle the various document types. */
-
-
-
- /*****************************************************************************/
-
-
-
- #include "App.h" /* Get the application includes/typedefs, etc. */
- #include "App.defs.h" /* Get various application definitions. */
- #include "App.protos.h" /* Get the prototypes for application. */
-
- #ifndef __ERRORS__
- #include <Errors.h>
- #endif
-
- #ifndef __UTILITIES__
- #include "Utilities.h"
- #endif
-
-
-
- /* In this file, we first set some global values. This allows the application and
- ** DTS.Lib..framework to "know" what is expected for certain default actions. */
-
-
- short gTypeListLen = 1;
- SFTypeList gTypeList = {kDocFileType};
- /* Here we declare the various document types that DTS.Draw can support.
- ** These definitions are to inform DTS.Lib..framework what documents can be opened. */
-
-
-
- /* Some DTS.Lib..framework gTypeList usage notes:
- **
- ** 1) Framework uses gTypeList[0] for the default document, if there is one.
- ** 2) NewDocument() is passed a document type. It searches gTypeList for a match.
- ** The index at which the match is found (+1) is used as the string number in the
- ** STR# resource rDefaultTitles. If there aren't enough strings in the STR#
- ** resource, then the last string is used.
- ** 3) The gTypeList is used for the StandardFile calls to determine which files
- ** can be selected. */
-
-
-
- #ifdef powerc
- #pragma options align=mac68k
- #endif
- typedef struct DocFileTypeRec { /* This is used only to determine the size of the document */
- FileStateRec fileState; /* structure. We can't just add the three components, as */
- ConnectRec connect; /* it is unclear how much padding any particular compiler */
- TheDoc doc; /* will place on the end of each. */
- } DocFileTypeRec; /* The only place that this should be used is in this file. */
- #ifdef powerc
- #pragma options align=reset
- #endif
-
-
-
- /* Below are the TreeObj procedure pointers for the various kinds of objects we use in this
- ** application. The first 16 are reserved for the framework. Our application-specific
- ** objects start at 16. */
-
- TreeObjProcPtr gTreeObjMethods[kNumTreeObjs] = {nil,
- /* 1 */ TRootObj,
- /* 2 */ TUndoObj,
- /* 3 */ TUndoTaskObj,
- /* 4 */ TUndoPartObj,
- /* 5 */ nil,
- /* 6 */ nil,
- /* 7 */ nil,
- /* 8 */ nil,
- /* 9 */ nil,
- /* 10 */ nil,
- /* 11 */ nil,
- /* 12 */ nil,
- /* 13 */ nil,
- /* 14 */ nil,
- /* 15 */ nil,
- /* 16 Start of app-specific procs. */ TRectObj,
- /* 17 */ TRRectObj,
- /* 18 */ TOvalObj,
- /* 19 */ TPieObj,
- /* 20 */ TLineObj,
- /* 21 */ nil, /* Reserve space for other */
- /* 22 */ nil, /* objects that may be added */
- /* 23 */ nil, /* to the tool palette. */
- /* 24 */ nil, /* The group object is never */
- /* 25 */ nil, /* going to be in the tool */
- /* 26 */ nil, /* palette, so put it far */
- /* 27 */ nil, /* enough away to leave room */
- /* 28 */ nil, /* for other objects. */
- /* 29 */ nil,
- /* 30 */ nil,
- /* 31 */ nil,
- /* 32 */ nil,
- /* 33 */ nil,
- /* 34 */ nil,
- /* 35 */ nil,
- /* 36 */ nil,
- /* 37 */ nil,
- /* 38 */ nil,
- /* 39 */ nil,
- /* 40 */ nil,
- /* 41 */ nil,
- /* 42 */ nil,
- /* 43 */ nil,
- /* 44 */ nil,
- /* 45 */ nil,
- /* 46 */ nil,
- /* 47 */ nil,
- /* 48 */ nil,
- /* 49 */ nil,
- /* 50 */ nil,
- /* 51 */ nil,
- /* 52 */ nil,
- /* 53 */ nil,
- /* 54 */ nil,
- /* 55 */ nil,
- /* 56 */ nil,
- /* 57 */ nil,
- /* 58 */ nil,
- /* 59 */ nil,
- /* 60 */ nil,
- /* 61 */ nil,
- /* 62 */ nil,
- /* 63 */ nil,
- /* 64 */ nil,
- /* 65 */ TGroupObj,
- /* 66 */ TExtSelectObj};
-
-
-
- /* The framework needs to know the minimum object sizes. This table is used by the
- ** framework to make sure that the object is created at least minimally. */
-
- long gMinTreeObjSize[kNumTreeObjs] = {0,
- /* 1 */ sizeof(RootObj),
- /* 2 */ sizeof(UndoObj),
- /* 3 */ sizeof(UndoTaskObj),
- /* 4 */ sizeof(UndoPartObj),
- /* 5 */ 0,
- /* 6 */ 0,
- /* 7 */ 0,
- /* 8 */ 0,
- /* 9 */ 0,
- /* 10 */ 0,
- /* 11 */ 0,
- /* 12 */ 0,
- /* 13 */ 0,
- /* 14 */ 0,
- /* 15 */ 0,
- /* 16 Start of app-specific sizes. */ sizeof(RectObj),
- /* 17 */ sizeof(RRectObj),
- /* 18 */ sizeof(OvalObj),
- /* 19 */ sizeof(PieObj),
- /* 20 */ sizeof(LineObj),
- /* 21 */ 0,
- /* 22 */ 0,
- /* 23 */ 0,
- /* 24 */ 0,
- /* 25 */ 0,
- /* 26 */ 0,
- /* 27 */ 0,
- /* 28 */ 0,
- /* 29 */ 0,
- /* 30 */ 0,
- /* 31 */ 0,
- /* 32 */ 0,
- /* 33 */ 0,
- /* 34 */ 0,
- /* 35 */ 0,
- /* 36 */ 0,
- /* 37 */ 0,
- /* 38 */ 0,
- /* 39 */ 0,
- /* 40 */ 0,
- /* 41 */ 0,
- /* 42 */ 0,
- /* 43 */ 0,
- /* 44 */ 0,
- /* 45 */ 0,
- /* 46 */ 0,
- /* 47 */ 0,
- /* 48 */ 0,
- /* 49 */ 0,
- /* 50 */ 0,
- /* 51 */ 0,
- /* 52 */ 0,
- /* 53 */ 0,
- /* 54 */ 0,
- /* 55 */ 0,
- /* 56 */ 0,
- /* 57 */ 0,
- /* 58 */ 0,
- /* 59 */ 0,
- /* 60 */ 0,
- /* 61 */ 0,
- /* 62 */ 0,
- /* 63 */ 0,
- /* 64 */ 0,
- /* 65 */ sizeof(GroupObj),
- /* 66 */ sizeof(ExtSelectObj)};
-
-
-
- /*****************************************************************************/
- /*****************************************************************************/
-
-
-
- /* •• Called by DTS.Lib..framework. •• */
-
- /* Do any additional document initialization here. All fields not specifically set
- ** are already initialized to 0. */
-
- #pragma segment File
- OSErr InitDocument(FileRecHndl frHndl)
- {
- OSErr err;
-
- err = noErr;
-
- switch ((*frHndl)->fileState.sfType) {
- case kDocFileType:
- err = DefaultInitDocument(frHndl, kVersion, kMaxNumUndos, kNumSaveUndos);
- if (!err) {
- (*frHndl)->d.doc.fhInfo.hDocSize = (7 * 72);
- (*frHndl)->d.doc.fhInfo.vDocSize = (10 * 72);
- }
- break;
- case kClipboardFileType:
- ClipboardInitDocument(frHndl);
- break;
- case kToolFileType:
- ToolInitDocument(frHndl);
- break;
- case 'PENS':
- (*frHndl)->fileState.initContentProc = PENSInitContent;
- (*frHndl)->fileState.freeWindowProc = PENSFreeWindow;
- break;
- #ifndef powerc
- case '6hlp':
- err = HelpInitDocument(frHndl);
- break;
- #endif
- #if VH_VERSION
- case kViewHierFileType:
- return(VHInitDocument(frHndl));
- break;
- #endif
- default:
- err = DefaultInitDocument(frHndl, kVersion, kMaxNumUndos, kNumSaveUndos);
- if (!err) {
- (*frHndl)->fileState.readDocumentProc = nil;
- (*frHndl)->fileState.writeDocumentProc = nil;
- }
- break;
- }
-
- return(err);
- }
-
-
-
- /*****************************************************************************/
-
-
-
- /* •• Called by DTS.Lib..framework. •• */
-
- /* Return the initial size of the primary document handle, based on the OSType. */
-
- #pragma segment File
- long InitDocumentSize(OSType sftype)
- {
- switch (sftype) {
- case kDocFileType:
- case kClipboardFileType:
- return(sizeof(DocFileTypeRec));
- break;
- #if VH_VERSION
- case kViewHierFileType:
- return(VHFileTypeSize());
- break;
- #endif
- default:
- return(sizeof(DocFileTypeRec));
- break;
- }
- }
-
-
-
-